package com.dameng.work.controller;


import com.alibaba.fastjson.JSON;
import com.dameng.work.pojo.SHELL;
import com.dameng.work.service.SHELLService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class ShellController {
    @Autowired
    private SHELLService sHELLService;


    @RequestMapping("/findAllShell")
    @ResponseBody
    public String findAllShell(){

        List<SHELL> findAllList = sHELLService.findAllList();

        Map<String, Object> returnMap = new HashMap<>();
        returnMap.put("state","1" );
        returnMap.put("result",findAllList);
        return  JSON.toJSONString(returnMap);

    }


    @RequestMapping("/insertShell")
    @ResponseBody
    public String insertShell() throws IOException {

        SHELL shell = sHELLService.InsertRandomShell();

        Map<String, Object> returnMap = new HashMap<>();
        returnMap.put("state","1" );
        returnMap.put("result",shell);
        return  JSON.toJSONString(returnMap);

    }

}
